package mathFrame

import scala.math._

case class Sin(parameter: Value*) 
extends LibMateFunction("Sin", Trigonometry.mateSin, parameter: _*)

case class Cos(parameter: Value*) 
extends LibMateFunction("Cos", Trigonometry.mateCos, parameter: _*)

object Trigonometry {
  def mateSin(xs: Double*) = {
    xs.length match {
      case 1 => sin(xs(0))
      case _ => Double.NaN
    }
  }
  
  def mateCos(xs: Double*) = {
    xs.length match {
      case 1 => cos(xs(0))
      case _ => Double.NaN
    }
  }
  
  def createSin(parameter: Value*) = new Sin(parameter: _*)
  
  def createCos(parameter: Value*) = new Cos(parameter: _*)
  
  def init = {
    JimParsers.addFunction("sin", createSin)
    JimParsers.addFunction("cos", createCos)
    JimParsers.addConstant("pi", new Constant("pi", new Number(3.14159265)))
  }
}
